/*
 * @Description:
 * @Autor: lcz
 * @Date: 2022-07-15 10:47:15
 * @LastEditors: lcz
 * @LastEditTime: 2022-07-15 10:47:37
 */
import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS'
import IconContext from '@ant-design/icons/lib/components/Context'
import { useContext, useEffect } from 'react'
export const useInsertStyles = (styleStr: string = iconStyles) => {
  const { csp } = useContext(IconContext)
  useEffect(() => {
    updateCSS(styleStr, '@ant-design-icons', {
      prepend: true,
      csp,
    })
  }, [])
}

export const iconStyles = `
.anticon {
  display: inline-block;
  color: inherit;
  font-style: normal;
  line-height: 0;
  text-align: center;
  text-transform: none;
  vertical-align: -0.125em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.anticon > * {
  line-height: 1;
}
.anticon svg {
  display: inline-block;
}
.anticon::before {
  display: none;
}
.anticon .anticon-icon {
  display: block;
}
.anticon[tabindex] {
  cursor: pointer;
}
.anticon-spin::before,
.anticon-spin {
  display: inline-block;
  -webkit-animation: loadingCircle 1s infinite linear;
  animation: loadingCircle 1s infinite linear;
}
@-webkit-keyframes loadingCircle {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@keyframes loadingCircle {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
`
